<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    let jsonStr = `
        {
            "name": "奉先",
            "age": 35,
            "sex": "男",
            "sports": ["足球","游泳","篮球"],
            "friends": [
                {
                    "name": "张三",
                    "sex": "男"
                },
                {
                    "name": "小红",
                    "sex": "女"
                }
            ],
            "girlFrined": null
        }
    `;

    // 把json字符串转为js对象（反序列化）
    let object = JSON.parse(jsonStr);

    console.log(object.name);
    console.log(object.sports);

    // 把js对象序列化为json字符串：
    let str = JSON.stringify(object);
    console.log("str =", str);
</script>
</html>